<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的社群</title>
    <meta name="viewport" content=" initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
    <script src="{$Think.config.RESOURCEURL}wx_assets/personCenter/js/mediaQuery.min.js{$Think.config.RESOURCE_VER}"></script>
    <script type='text/javascript' src='{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}'></script>
    <script src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}"></script>
    <style>
        article {
            font-size: 0;
        }
        h3 {
            font-size: .3rem;
            height: .75rem;
            line-height: .75rem;
            color: #fff;
            background: #ff9900 ;
            text-align: center;
        }
        .top {
            margin: .1rem .2rem;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            background: url({$Think.config.RESOURCEURL}wx_assets/commune/images/shbg.png{$Think.config.RESOURCE_VER}) center no-repeat;
            background-size: 6.2rem 5.5rem;
            height: 5.5rem;
            padding: .4rem 0;
        }
        .top > p {
            background: url({$Think.config.RESOURCEURL}wx_assets/commune/images/my_group.png{$Think.config.RESOURCE_VER}) 4% center no-repeat;
            background-size: .7rem .69rem;
            height: .69rem;
            line-height: .69rem;
            font-size: .24rem;
            color:#ff9900;
            padding-left: 19%;
        }
        .top > span {
            display: block;
            height: .4rem;
            line-height: .4rem;
            background: url({$Think.config.RESOURCEURL}wx_assets/commune/images/clock.png{$Think.config.RESOURCE_VER}) 26% center no-repeat;
            background-size: .31rem .34rem;
            text-align: center;
            margin-top: .5rem;
            font-size: .2rem;
            color:#757575;
        }
        .top > span.ss {
            background: url({$Think.config.RESOURCEURL}wx_assets/commune/images/clock.png{$Think.config.RESOURCE_VER}) 32% center no-repeat;
            background-size: .31rem .34rem;
        }
        .top > span i {
            color: #ff9900;
        }
        .top .sign {
            position: relative;
            width: 2.1rem;
            height: 2.1rem;
            line-height: 2.1rem;
            border-radius: 50%;
            border: 1px solid #ff9900;
            margin: .3rem auto .4rem;
            color:#ff9900;
            text-align: center;
            font-size: .56rem;
            background: url({$Think.config.RESOURCEURL}wx_assets/commune/images/shw.png{$Think.config.RESOURCE_VER}) center no-repeat;
            background-size: 2rem 2rem;
        }

        .top .signed i {
            font-size: .8rem;
        }
        .top .sign.signed {
            background: url({$Think.config.RESOURCEURL}wx_assets/commune/images/shr.png{$Think.config.RESOURCE_VER}) center no-repeat;
            background-size: 2rem 2rem;
            color: #fff;
        }
        .top .sign em {
            position: absolute;
            top: .25rem;
            left: 50%;
            transform: translateX(-50%);
            -webkit-transform: translateX(-50%);
            font-size: .3rem;
            display: inline-block;
            height: .3rem;
            line-height: normal;
        }
        .top > i {
            font-size: .24rem;
            color: #757575;
            display: block;
            text-align: center;
        }
        .day {
            padding: 0 .3rem;
            font-size: .24rem;
            color: #ff9900;
        }
        .day.ed {
            margin-top: .2rem;
        }
        .day span {
            font-size: .2rem;
            color: #a3a3a3;
            padding-left: .3rem;
            background: url({$Think.config.RESOURCEURL}wx_assets/commune/images/sclock.png{$Think.config.RESOURCE_VER}) left no-repeat;
            background-size: .23rem .25rem;
        }
        .fr {
            float: right;
        }
        .info {
            font-size: .24rem;
            color: #a3a3a3;
            margin-top: .2rem;
        }
        .info > img {
            width: .76rem;
            height: .76rem;
            vertical-align: middle;
            margin-left: .55rem;

        }
        .info em {
            margin-top: .5rem;
            display: block;
            font-size: .24rem;
            color: #323232;
            text-align: center;
            text-decoration: underline;;
        }
        .info i {
            display: block;
            text-align: center;
            margin-top: .06rem;
        }
        .info span {
            display: inline-block;
            margin-left: .55rem;
        }
        .info .tac {
            width: 57%;
            margin-left: 0;
            text-align: center;
        }
        .gz {
            height: 1.46rem;
            margin-top: .15rem;
            text-align: center;
        }
        .gz p {
            margin-top: .15rem;
        }
        .gz img {
            width: 1.2rem;
            height: 1.2rem;
            margin-right: .4rem;
        }
        .gz img:nth-child(2) {
            margin-right: 0;
            padding-left:.4rem;
            border-left: 1px solid #ccc;
        }
    </style>
</head>
<body>
   <article>
       <h3>
           社群签到
       </h3>
       <div class="top">
           <p>{$results.groupName}</p>
           <if condition="$results.status eq 1">
               <span>距群签到结束：<i id="only">{$results.thetime}</i></span>
               <else/>
               <span class="ss">群签到尚未开始</span>
           </if>
           <if condition="($results.status eq 1) AND ($results.sign eq 1)">
               <div class="sign signed">
                   <i>{$results.ranking}</i>
                   <em class="show">排名</em>
               </div>
               <elseif condition="($results.status eq 1) AND ($results.sign eq 0)"/>
               <div class="sign" id="sign">
                   <i>签&nbsp;到</i>
                   <em></em>
               </div>
               <else/>
               <div class="sign">
                   <i>签&nbsp;到</i>
                   <em></em>
               </div>
           </if>
           <if condition="($results.status eq 0) OR ($results.status eq 2)">
               <i>发送到微信群开始签到</i>
           </if>
       </div>
       <if condition="$results.sign eq 0">
           <p class="day"><i>今日未签到</i></p>
           <else/>
           <p class="day ed"><i>今日已签到</i> <span class="fr time">{$results.clickTime}</span></p>
       </if>
       <div class="info">
           <if condition="($results.subscribe eq 'sharesubscribe') OR ($results.subscribe eq 'unsubscribe')">
               <img src="{$Think.config.RESOURCEURL}wx_assets/commune/images/info_def.png{$Think.config.RESOURCE_VER}" alt="">
               <span class="tac">您未关注{$results.qr_name}公众号</span>
               <div class="gz">
                   <img src="" alt=""  class="er">
                   <img src="{$Think.config.RESOURCEURL}wx_assets/commune/images/zw.gif{$Think.config.RESOURCE_VER}" alt="">
                   <p>长按识别二维码</p>
                   <i>(关注可获得头像和昵称)</i>
               </div>
               <else />
               <img src="{$results.headimgurl}" alt="">
               <span>{$results.nickname}</span>

           </if>
       </div>
   </article>
<script>
    function getRTime(){
        var EndTime='{$results.endTime}'.replace(/\-/g, "/")
        EndTime= new Date(EndTime);
        var NowTime = new Date();
        var t =EndTime.getTime() - NowTime.getTime();
        var d=Math.floor(t/1000/60/60/24);
        var h=Math.floor(t/1000/60/60%24);
        var m=Math.floor(t/1000/60%60);
        var s=Math.floor(t/1000%60);
        dd = checkTime(d);
        hh = checkTime(h);
        mm = checkTime(m);
        ss = checkTime(s);
        $("#only").text(hh+':'+mm+':'+ss)
    }
    setInterval(getRTime,1000);
    function checkTime(i)
    {
        if (i < 10) {
            i = "0" + i;
        }
        return i;
    }

    $("#sign").click(function(){
        var parm = {"gid":gid};
        parm = encodeURIComponent(JSON.stringify(parm));
        var surl = '{$Think.config.SERVER_HOST}call.json?customerId={$results.customerId}&module=commune&method=communeShareView&params=' + parm;
        $.get(surl,function(data){
            var obj = eval('(' + data + ')');
            $(".sign").addClass('signed');
            $(".sign i").text(obj.results.ranking).addClass('big');
            $(".sign em").text('排名');
            $("article > .day").html('<i>今日已签到</i> <span class="fr time"></span>')
            $("article > .day .time").text(obj.results.clickTime);
        });
    })
    var url = "{$Think.config.SERVER_HOST}call.json?customerId={$customerId}";
    var gid = '{$results.id}';
    var data = {
        "qid":'{$results.qr_id}',
        "uid":'{$results.qr_uid}',
        "mallId":'{$results.qr_mallId}'
    }
    $.ajax({
        type: 'get',
        url: url,
        dataType: 'json',
        data:{
            'module':"community",
            "method":"miQrcode",
            "params":JSON.stringify(data)
        },
        success: function(data){
            $(".gz .er").attr("src",data);
        },
        error: function(xhr, type){
//            alert('Ajax error!')
        }
    })
    var params = {"gid":gid};
    params=encodeURIComponent(JSON.stringify(params));
    var shareUrl = "{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=commune&method=communeSign&params="+params;
    wx_share.init({
        "title":"群签到:{$results.groupName}",
        "desc":'看看你的签到能排第几',
        "link":shareUrl,
        "imgUrl": '{$Think.config.RESOURCEURL}wx_assets/commune/images/my_group.png{$Think.config.RESOURCE_VER}',
        "pkg":{
            "appId": '{$pkg.appId}',
            "timestamp": '{$pkg.timestamp}',
            "nonceStr": '{$pkg.nonceStr}',
            "signature": '{$pkg.signature}'
        },
        success:function(){
            var par = {"gid":gid};
            par = encodeURIComponent(JSON.stringify(par));
            var surl = '{$Think.config.SERVER_HOST}call.json?customerId={$customerId}&module=commune&method=updateShareTime&params=' + par;
            $.get(surl,function(){

            });
        }
    });

//    wx.hideMenuItems({
//        menuList: ["menuItem:share:timeline"]
//    });
</script>
</body>
</html>